package com.example.mode.adapter;

import androidx.databinding.DataBindingUtil;

import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.mode.R;
import com.example.mode.databinding.ActivityMainItemBinding;
import com.example.mode.entity.DEntity;
import com.squareup.picasso.Picasso;
import com.utils.conmponentbase.base.adapter.BaseLoadMoreAdapter;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
 * MvvmDemo com.example.mode.adapter
 * 2020-01-04 17:47
 */
public class MainAdapter extends BaseLoadMoreAdapter<DEntity, BaseViewHolder> {

    public MainAdapter(@Nullable List<DEntity> data) {
        super(R.layout.activity_main_item, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder pBaseViewHolder, @Nullable DEntity pDEntity) {
        if (null == pDEntity) return;
        ActivityMainItemBinding binding = pBaseViewHolder.getBinding();
        if (null != binding) {
            binding.setData(pDEntity);
            Picasso.get().load(pDEntity.image).into(binding.image);
        }
    }
}
